<template>
  <div>
    <el-button class="filter-item" type="primary" @click="printPreview(0)">直接打印</el-button>
    <el-button class="filter-item" type="success" @click="printPreview(1)">打印预览</el-button>
    <el-button class="filter-item" type="danger" @click="printPreview(2)">打印维护</el-button>
    <el-button class="filter-item" type="primary" @click="printPreview(3)">打印设计</el-button>
    <form id="form1">

    </form>
  </div>
</template>
<script>
import { getLodop } from '@/const/lodop'
export default {
  data () {
    return {
      LODOP: null
    }
  },
  methods: {
    printPreview (s) {
      this.CreateOneFormPage()
      if (s == 0) {
        this.LODOP.PRINT() //直接打印
      }
      if (s == 1) {
        this.LODOP.PREVIEW() //打印预览
      }
      if (s == 2) {
        this.LODOP.PRINT_SETUP() //打印维护
      }
      if (s == 3) {
        this.LODOP.PRINT_DESIGN() //打印设计
      }
    },
    CreateOneFormPage () {
      this.LODOP = getLodop()
      //样式
      var olstyle1 = '<style>' + document.getElementById('olstyle1') + '</style>'
      var body = olstyle1 + '<body>' + document.getElementById('form1').innerHTML + '</body>'
      this.LODOP.PRINT_INIT('订单') //打印初始化
      this.LODOP.SET_PRINT_STYLE('FontSize', 18) //设置对象风格
      this.LODOP.SET_PRINT_STYLE('Bold', 1) ////设置对象风格
      this.LODOP.ADD_PRINT_TEXT(50, 521, 130, 39, this.description) //增加纯文本项
      this.LODOP.SET_PRINT_PAGESIZE(0, 2000, 2000, '') //设定纸张大小
      this.LODOP.SET_PRINT_MODE('PRINT_PAGE_PERCENT', '55%')//设置缩放
      this.LODOP.SET_PREVIEW_WINDOW(2, 2, 0, 0, 0, '')//设置窗口
      // 打印二维码
      // LODOP.ADD_PRINT_BARCODE(23,23,233,233,"QRCode","https://blog.csdn.net/qq_43652509");
      //打印网址
      // LODOP.ADD_PRINT_URL(222,2000,2000,233,"https://blog.csdn.net/qq_43652509");
      //打印图片
      // LODOP.ADD_PRINT_IMAGE(100,100,400,400,"<img border='0' src='http://s1.sinaimg.cn/middle/4fe4ba17hb5afe2caa990&690' width='345' height='250'>");
      this.LODOP.ADD_PRINT_HTM(88, 20, 2000, 2000, body) //增加超文本项
    }
  },
}
</script>